package com.fly.springbootTemplate.controller;

import com.fly.springbootTemplate.entity.Book;
import com.fly.springbootTemplate.service.BookService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    private BookService bookService;
    @PostMapping("/addBook")
    public boolean addBook(Book book){
        return bookService.addBook(book);
    }
    @DeleteMapping("/deleteBook")
    public boolean deleteBook(Integer id){
        return bookService.deleteBook(id);
    }
    @PutMapping("/updateBook")
    public boolean updateBook(Book book){
        return bookService.updateBook(book);
    }
    @GetMapping("getAllBook")
    public List<Book> getAllBook(){
        return bookService.getAllBook();
    }
    @GetMapping("getOneBook")
    public Book getOneById(Integer id){
        return bookService.getOneBookById(id);
    }
}
